public class PrintOut extends Quaternion{
    private String str;
    private Pairs exp;
    private int type;   //0 :str 1：%d
    private Pairs address;

    public PrintOut(String str) {
        super(OP.PRINT);
        this.str = str;
        this.type = 0;
    }

    public PrintOut(Pairs exp) {
        super(OP.PRINT);
        this.exp = exp;
        this.type = 1;
    }

    public PrintOut(Pairs exp,Pairs address) {
        super(OP.PRINT);
        this.exp = exp;
        this.type = 1;
        this.address = address;
    }

    public int getType() {
        return this.type;
    }

    public String getStr() {
        return this.str;
    }

    public Pairs getExp() {
        return this.exp;
    }

    public Pairs getAddress() {
        return this.address;
    }

    public String toString() {
        if (type == 0) {
            return opToString() + " " + "\"" + str + "\"" + "\n";
        }  else {
            if (address!= null) {
                return opToString() + " " + exp.getToken() + "[" + address.getToken() + "]" + "\n";
            }
            return opToString() + " " + exp.getToken() + "\n";
        }
    }
}
